<template>
  <div>
    <div>
      <van-nav-bar
        title="班级"
        left-arrow
        right-text="完成"
        @click-left="onClickLeft"
        @click-right="onClickRight"
      />
    </div>
    <van-cell-group>
      <van-field v-model="value"  placeholder="请填写班级" />
    </van-cell-group>
  </div>
</template>
<script>
import Vue from "vue";
import { NavBar } from "vant";
import { Toast } from "vant";
Vue.use(NavBar);
export default {
  name: "unitsetting",
  data(){
    return{
      value:''
    }
  },

  mounted(){
   this.userid=localStorage.getItem("userId")
  },
  methods: {
    onClickLeft() {
      // Toast('返回');
      this.$router.go(-1);
    },
    onClickRight() {
      Toast("按钮");
      this.axios({
        url:"http://localhost:3000/change_class",
        method:'post',
        data:{
          userId:this.userid,
          data:this.value
        }
      }).then((res)=>{
        console.log(res)
        if(res.data.affectedRows==1){
            Toast("添加班级成功")
            this.$router.push("management")
        }
      })
    },
  },
};
</script>
<style scoped>
.content {
  text-align: center;
  border: 1px rgb(180, 175, 175) solid;
}
/deep/.van-icon {
  color: rgb(13, 14, 14);
}
/deep/.van-nav-bar__text {
  color: black;
}
</style>